package com.icore.service;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.icore.mapper.UserMapper;
import com.icore.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {

    @Autowired
    UserMapper userMapper;


    public int deleteByPrimaryKey(Integer id) {
        return userMapper.deleteByPrimaryKey(id);
    }

   
    public int insert(User record) {
        return userMapper.insert(record);
    }

   
    public int insertSelective(User record) {
        return userMapper.insertSelective(record);
    }

   
    public User selectByPrimaryKey(Integer id) {
        return userMapper.selectByPrimaryKey(id);
    }

   
    public int updateByPrimaryKeySelective(User record) {
        return userMapper.updateByPrimaryKeySelective(record);
    }

   
    public int updateByPrimaryKey(User record) {
        return userMapper.updateByPrimaryKey(record);
    }


    public PageInfo<User> selectAll(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<User> users = userMapper.selectAll();
        PageInfo<User> pageInfo = new PageInfo<>(users);
        return pageInfo;
    }

   
    public User selectByUsernamePass(String username, String password) {
        return userMapper.selectByUsernamePass(username,password);
    }

   
    public User selectByUsername(String username) {
        return userMapper.selectByUsername(username);
    }
}
